<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>产品库存预警分析</title>
    <script type="text/javascript">
      Ext.onReady(function(){
               
        var submitButton = Ext.create('Ext.Button', {
          text: '执行统计',
          iconCls: 'finding',
          handler: function(){
            if (queryFormPanel.form.isValid()) {
              statsResultDS.removeAll();
              statsResultDS.load();
            }
          }
        });

        var queryFormPanel = Ext.create('Ext.form.Panel', {
          fieldDefaults: {
            labelWidth: 65,
            labelAlign: 'right'
          },
          width: screenWidth-165,
          frame : true,
          border:false,
          items: [submitButton]
        });
        //显示销售订单操作时的窗口介面。
        //----------------------------------销售订单Grid-------------------------
        Ext.define('ProductStockRemindReport', {
          extend : 'Ext.data.Model',
          fields : [{
              name: 'id'
            },{
              name: 'name'
            },{
              name: 'number'
            },{
              name: 'min_quantity',
              type: 'int'
            },{
              name: 'max_quantity',
              type: 'int'
            },{
              name: 'quantity',
              type: 'int'
            }]
        });

        
        //销售订单Grid Store
        var statsResultDS = Ext.create('Ext.data.Store', {
          //autoDestroy : true,
          model : 'ProductStockRemindReport',
          proxy : {
            type : 'ajax',
            url : '/purchase_order/getProductStockRemindForReport',
            reader : {
              type : 'json',
              root : 'root',
              totalProperty : 'totalProperty'// 数据集记录总数
            }
          }
        });

        //生成要订单的产品的Grid
        var statsResultGrid = Ext.create('Ext.grid.Panel', {
          title:'统计结果列表',
          store: statsResultDS,
          columns : [Ext.create('Ext.grid.RowNumberer',{width: 40}),{
              header: '产品名称',
              dataIndex: 'name',
              width: 230
            },{
              header: '产品编号',
              dataIndex: 'number',
              width: 170
            },{
              header: '预警最小值',
              dataIndex: 'min_quantity',
              align:'right',
              width: 130
            },{
              header: '预警最大值',
              dataIndex: 'max_quantity',
              align:'right',
              width: 130
            },{
              header: '当前库存数量',
              dataIndex: 'quantity',
              align:'right',
              width: 130
            }],
          loadMask: true,
          width: screenWidth-165,
          height: screenHeight-300,
          frame: true         
        });    

        //总的panel
        var workbenchPanel = Ext.create('Ext.form.Panel', {
          width: screenWidth-165,
          height: screenHeight-240,
          frame:false,          
          layout: {type: 'table',columns:1},          
          items:[queryFormPanel,statsResultGrid]
        });
        workbenchPanel.render("product_stock_remind_report_workbench_panel");
      })
    </script>
  </head>
  <body>
    <div id="product_stock_remind_report_workbench_panel"></div>
  </body>
</html>